package com.nan.buy.service.Impl;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.nan.buy.common.UUIDUtil;
import com.nan.buy.dao.NoticeMapper;
import com.nan.buy.model.Notice;
import com.nan.buy.service.NoticeService;

@Service
public class NoticeServiceImpl implements NoticeService {

	@Resource
	private NoticeMapper noticeMapper;
	
	@Override
	public List<Notice> searchNotices() {
		return noticeMapper.searchNotices();
	}

	@Override
	public int deleteByPrimaryKey(String nId) {
		return noticeMapper.deleteByPrimaryKey(nId);
	}

	@Override
	public int updateNotice(Notice notice) {
		Date date=new Date();
		String dateStr = new SimpleDateFormat("MM-dd-yyyy").format(date);
		notice.setnTime(dateStr);
		return noticeMapper.updateByPrimaryKeySelective(notice);
	}

	@Override
	public int addNotice(Notice notice) {
		Date date=new Date();
		String dateStr = new SimpleDateFormat("MM-dd-yyyy").format(date);
		notice.setnTime(dateStr);
		notice.setnId(UUIDUtil.getUUID());
		return noticeMapper.insertSelective(notice);
	}

}
